Showing posts with label performance. Show all posts
Showing posts with label performance. Show all posts

Sunday, 26 March 2017

This week 6/2017

I did fast research of Vue.js (v. 2.2.2) and I'd like to summary what I got to know about it and how it presents itself in compared to Angular 2 and what I think about it.

1. Performance
Project krausest/js-framework-benchmark tested over 20 JavaScript frameworks, below are results.

src: js-frameworks-benchmark4

As you can see in most cases Angular 2 is slower than Vue.js.


2. Size of attached scripts.
In my case small Angular 2 project with 3 additional modules takes 800kb (prod version and after minification). I wonder to know what will be the size with Vue.js. I found comparison of raw frameworks on Vuejs's web side. Vue.js size is about 23kb but Angular 2 about 50kb. It's really interesting....


3. Learning curve
The creators of Vue framework estimate that it is possible to learn their framework in one day or faster if you know AngularJs. I will see ...
In my opinion to learn Angular 2 in one day is impossible. The same is with AngularJs but I think it was easier then with Angular 2.

4. Testing
On project web page unit testing looks similar to Angular Js or Angular 2 unit.



Resources:
  1. https://github.com/krausest/js-framework-benchmark
  2. http://stefankrause.net/js-frameworks-benchmark4/webdriver-ts/table.html
  3. http://www.valuecoders.com/blog/technology-and-apps/vue-js-comparison-angular-react/
  4. https://vuejs.org/v2/guide/comparison.html#Angular-2

Friday, 3 February 2017

This week 2/2017

One hopeless project in which I have taken a part has been taught me a few tricks in distribution database architecture, where each database has his specific rule in my organisation.

Remote queries
In my solution take a part 3 oracle 11g+ databases:
1. DB A - designed as storage of all changes applied on source system database,
2. DB D - designed as storage of reports - data warehouse
3. DB B - target database where I need to collect specific data from other databases and generate some report.
To get data from A and D I use dblink.
At the begging I created plain pl/SQL queries with business logic. When I executed them first time, I exceeded database temp area (128G). It was impossible to get data without a few tricks.
At beginning I have to describe what happened. So... if I have join like this:


1
2
3
4
5
6
7
8
9
SELECT A.ID,
       A.NAME,
       B.NAMEB
  FROM TAB_A@REMOTE_DB A
  LEFT JOIN TAB_B@REMOTE_DB B
    ON (A.ID =B.ID)
 WHERE B.ID IN (SELECT C.FK_ID
                  FROM TAB_C@REMOTE_DB C
                 WHERE C.NAME ='Tom') 

Database B executes 3 queries, transfer data from remote database to local area and locally matches them.
If we have huge tables but result of that select returns much less rows it's mean that this query should be executed remotely and only results should be transferred to client.
To force database to do something like this, there is a hint:


1
DRIVING_SITE(remote-table-alias)

Unfortunately my experiences shows that it doesn't work with materialised views, creating tables from query, etc. Anyway I found workaround for this problem using procedure with declared cursor. This way I could insert data from query executed fully remotely.
In my case this solution was useful only during testing. Finally I have to move logic on server side and create some views on server side.

Parallel execution
Second useful hint is to force database to execute query in parallel mode.

1
PARALLEL(4)

This mode doesn't work throw dblink as most hints but it is useful locally.


Materialized view

I had a chance to test performance of creating and refreshing materialized views for remote queries which I described above. Result of that tests are bellow:

Description of case Estimated time cost [sek]
create the materialized view 100
refresh the materialized view by execution
DBMS_MVIEW.REFRESH(MVIEW_NAME)
3000
truncate container table and refresh the materialized view by execution
DBMS_MVIEW.REFRESH(MVIEW_NAME, ATOMIC_REFRESH => FALSE)
104
drop and create a materialized view 110
refresh by execution
DBMS_MVIEW.REFRESH(MVIEW_NAME, ATOMIC_REFRESH => FALSE)
98
refresh the materialized view by execution
DBMS_MVIEW.REFRESH('MVIEW_NAME', PARALLELISM => 4, ATOMIC_REFRESH => FALSE);
94

By default materialized view has ATOMIC_REFRESH set to true and all operation are made in transaction one by one. In my case it is not required.

When refreshing more than one materialized view it is possible to do that parallel by execution list of materialized views, ex:

DBMS_MVIEW.REFRESH(LIST => 'MV_A,MV_B,MV_C', PARALLELISM => 4, ATOMIC_REFRESH => FALSE);

If there are some dependences between materialized views, it is possible to turn on specialised analyser but I didn't use it.


Grouping in partitions
By the way PL/SQL allows to grouping in some subgroups. Ex.
If there is a table with not unique customer numbers and it is needed to get his last inserted name, it is possible to do this by query:


1
2
3
4
5
6
7
8
9
SELECT GC.* 
FROM (SELECT P.ID,
             P.NAME,
             P.CUSTOMER_NO,
             ROW_NUMBER() OVER(PARTITION BY P.CUSTOMER_NO 
                                   ORDER BY P.ID DESC) AS ROW_NUMBER 
        FROM MY_CUSTOMERS P ) GC 
WHERE GC.CUSTOMER_NO = 12345 
  AND GC.ROW_NUMBER = 1


Saturday, 27 August 2016

This week 13/2016

This week I was creating a functionality. An independent service to export large part of data to MS Excel file and part of service which retrieve data from database. It is obvious that xls format can contain about 65 thousand of rows, so I decided to use xlsx format which I thought it is unlimited but about this it will be later. My requirement was to export from database to excel a large set of data and not kill application. 

First of all I focused on the output. The solution was to not use a XSSFWorkbook but SXSSFWorkbook. In my application currently I use old version of Apache POI v3.7 and there isn't implemented SXSSFWorkbook so in this case there is impossible to solve my problem. SXSSFWorkbook is available from v3.8.
However what I could do after I upgrade a libraries? I checked and it is possible to export huge part of data using less then 64MB heap memory.  The SXSSFWorkbook implementation can save simple data in a stream. Process of creating file is split into two phases. In the first phase implementation is saving processed data into temporary file (on linux it is /tmp/.... file). In the second phase temporary xml file is compressed with additional files containing styles and other information into final file.

By the way I found out that xlsx is not unlimited and every sheet can have maximum a little more then one million rows (2^20) and about 16 thousand columns (2^14).

After I had found out how to export large volume of data to xlsx I looking for solution how to retrieve data from database row by row. I'd like to separate input from output service. I created interface of DataProvider and injected there a RowMapper and other types used in NamedParameterStatement's query method but it doesn't work. Finally I used a ScrollableResultSet with Forward option and limitation of retrieved data at once and it works.


Saturday, 20 August 2016

This week 12/2016

I watched a few presentation about jvm and a garbage collection. Today I will write about topics which are new for me.

I didn't know that:...

1. JVM have a lot of parameters (a few hundreds) and some of them are manageable. It is possible to change their state in runtime (about hundred).

2. Bytecode is compiled by JIT into processor code in runtime but there are a few types of compiled code, depending of:
- free memory for compiled code - every platform have other size of memory
- frequency of usage - often used part of code is better optimised then used onece,
- count of processors and cores,
- complication of code's part.

3. Log4J retrieve logged line of code by dumping a stack trace. It is an expensive operation.
4. New one GC called G1 solve a fragmentation of data by splitting memory area into blocks.