Arquivo

Posts Tagged ‘Performance’

Utilizando melhor o comando TOP no Linux/Unix/Solaris

Utilizo muito o comando TOP (dentre outros) para medir a “saúde” de nossos servidores. Duas opções que gosto muito são o “1” e o “I” (maiusculo).

Apertando 1, o TOP mostra todos os cores de seu processador, o que ajuda a ver sua utilização como um todo.

selection_070

Utilizando o I (letra í maiuscula), você desabilita o “Irix mode”, apertando novamente você o habilita. Basicamente desabilitando o Irix mode, você mostra a utilização da CPU levando em conta sua capacidade real em %. Dando um exemplo, no Irix mode que é o padrão, você pode observar que alguns processos podem consumir mais que 100% de utilização. Isso acontece pois nesse modo ele considera o total de cores que você tem * 100%. Desabilitando o mesmo, o TOP divide a utilização do processo pelo numero todal de CPUs que você tem, levando a um numero mais realista e que não vai passar de 100%. As imagens abaixo mostram primeiro o TOP com a opção padrão (Irix Mode) e logo após, desabilitando o Irix Mode, note que os processos marcados tiveram sua utilização de CPU “diminuída”, porém, não é o caso, ele simplesmente está mostrando a utilização da CPU como um todo.

selection_071selection_072

Enjoy!

Finding bottlenecks at Watson Explorer queries

If you are having problem with some Watson Explorer query, an excellent way to find bottlenecks is to perform the query with Debug and Profile options enabled, it will help you to find where exactly you have problems.

Usually, when you perform a query at WEX, you call some URL like the following (in my case port is 7205, MY_COLLECTION can be a shard, for example MY_COLLECTION_1_1):

<SERVER>:<PORT>/search?collection=MY_COLLECTION&query-xml=<%3fxml version%3d”1.0″ encoding%3d”UTF-8″%3f><operator logic%3d”and”%2f>&num=1&max=1&binning-mode=normal&start=0&show-duplicates=1&doc-axl=<%3fxml version%3d”1.0″ encoding%3d”UTF-8″%3f><document key-hash%3d”{vse%3adoc-hash()}”%2f>&binning-config=<%3fxml version%3d”1.0″ encoding%3d”UTF-8″%3f><binning-sets><binning-set bs-id%3d”VENDOR” logic%3d”or” max-bins%3d”8″ select%3d”%24VENDOR”%2f><binning-set bs-id%3d”REVENUE_USD_FACET” logic%3d”or” max-bins%3d”11″ select%3d”%24REVENUE_USD_FACET”%2f>……………field%3d”SERVICE_AREA”><field-to name%3d”SERVICE_AREA”%2f><%2ffield-map><field-map field%3d”MAX_IGS_REV_OM_BRAND_CD”><field-to name%3d”MAX_IGS_REV_OM_BRAND_CD”%2f><%2ffield-map><field-map field%3d”EMAIL_SENT”><field-to name%3d”EMAIL_SENT”%2f><%2ffield-map><field-map field%3d”REVENUE_USD_FACET”><field-to name%3d”REVENUE_USD_FACET”%2f><%2ffield-map><field-map field%3d”REVENUE”><field-to name%3d”REVENUE”%2f><%2ffield-map><field-map field%3d”CLIENT_NAME”><field-to name%3d”CLIENT_NAME”%2f><%2ffield-map><%2ffield-mapping>&sort-keys=1&score=1&shingles=0&summarize=0&gen-key=0&cache-data=0&force-binning=1&output-acls=1

If you don’t have IDEA about HOW to get the query that your Application is doing, you can enable Debug at your collection. Go to WEX console, under Configuration -> Searching -> Debugging and enable Query Logging.

Selection_355

When saved, it will start to generate log in a file called queries.log, under you collection folder, some place like:

/opt/IBM/dataexplorer/WEX-11/Engine/data/search-collections/YYY/MY_COLLECTION/crawl1/

You can check it at WEX console, under your collection configuration, tab META, field Filebase.

Ok, now, if you call this URL from your browser, appending “&debug=1&profile=1″ to the URL, you will got a XML file. Download it and lets analyze. For our case, see this:

<xpath-performances>
<xpath-performance xpath=”($FIELD_X) = ‘GBS – No’ or ($FIELD_X) = ‘GBS – Yes'” slow-ms=”10295″ n-slow=”192000″ n-fast=”0″ n-direct=”0″ n-hashes=”1″ />
</xpath-performances>

THIS tell me that JUST in order to get the field FIELD_X, I’m having slow! (I’m my case it is because my Field its an Array)

So, probably I have a problem with this field, that can be a lot, for example:
1- Null values (see my other posts)
2- Its an array to index
3- Its a long text field
4- You have a lot of possible statements using it (OR, AND, WHERE, etc)

With this information, you can go to next step, that is find a way to change the field and make it work better.

Important: I tested this with Watson Explorer 9, 10 and 11. Running at Linux Machines.

Enjoy!

Watson Explorer performance decrease with null values

Working with Watson Explorer (WEX) we saw that the search performance decrease a lot when you have null values for some field/facet. (Our WEX release at this moment is 11, we run at Linux machines and our application was written in Java, using BigIndex to index and search. (Also have pure REST version of our application in test and the problem still happen)).

For example: lets suppose that you have a facet called VENDOR in an entity called Product. Suppose that you have 5 millions Products indexed and for some of then you have nulls, in my case 2 Millions have NULL values for VENDOR field.

In this case (and similar ones), we notice a performance decrease in searches. We start to see problems when the relation of null are greater than 20%.

In order to solve the problem we have 2 options:

1- One technique we’ve used for certain dimensions is to always ensure non-null values in the index — so at index time, we either coalesce in our SQL pulls from DB2 or do transformation after ingestion to replace nulls with some predefined value. In our case we use the literal string “(no value available)”.  It: a) ensures non-null values, b) is fairly meaningful to users, and c) gives users a way to actually filter on those records if needed.

2- For some FIELDS, we can not add another values, must leave null (Business reasons) and must not show null option to user select in the facet. In this case, in the moment of search we append boolean($FIELD) to the query. For example:

General example of a slow facet query:
$VENDOR=’IBM or $VENDOR=’PEPSICO’
Rewritten query that solve the slowness:
boolean($VENDOR) and ($VENDOR=’IBM or $VENDOR=’PEPSICO’)
This way, it ignore the null values when searching and it will be very fast.
Maybe this is not the final solution and for newer WEX versions it will handle better with null values, but, this was the solution for us.
Enjoy!

Slides – Palestra: Desmistificando Tecnologias

Como prometido, seguem os slides da minha palestra: Desmistificando Tecnologias.

Performance Tip for Eclipse/RAD/RSA

A simple thing that we can do in order to have a Faster Eclipse its move our Java installation from Hard Disk to RAM (memory). In order to do this you should install Squash. Here is the steps that I follow for Ubuntu Linux, you can use to research about and do it, please, remember to change to your folders:

  • mkdir /media/ramdisk
  • mount -t tmpfs tmpfs /media/ramdisk
  • Add the following line to /etc/fstab

tmpfs /media/ramdisk tmpfs defaults,mode=1777 0 0

  • Reboot

Using the command “df -h” you should see the disk.

  • Install squashfs
    apt-get install squashfs-tools
  • Create .sqsh file
    mksquashfs /opt/java /home/julianom/jdk.sqsh
  • This is just to test, mount and see if Java is present at the folder:

mount /home/julianom/jdk.sqsh /media/ramdisk -t squashfs -o loop

  • Edit fstab – add more this lines (remember, use your own folder, change julianom)
    /home/julianom/jdk.sqsh /media/ramdisk squashfs ro,defaults,loop 0 0
  • update alternatives
    update-alternatives –install “/usr/bin/java” “java” “/media/ramdisk/bin/java” 1

There are 3 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
————————————————————
0 /usr/lib/j2re1.7-ibm/jre/bin/java 1200 auto mode
* 1 /media/ramdisk/bin/java 1 manual mode
2 /usr/lib/j2re1.7-ibm/jre/bin/java 1200 manual mode
3 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode

Do not forget to change your Eclipse/RSA to run with the JRE from this place.

Enjoy!

Categorias:JAVA Tags:, , ,

SQL: FOR READ e WITH UR

Muitas pessoas desconhecem as clausulas FOR READ e WITH UR, muito utilizadas em buscas em banco de dados, e que podem fazer uma imensa diferença na performance de sua aplicação/DB. Segue um pequeno exemplo que pode ser útil:

No caso:

SELECT * FROM TABELA FETCH FIRST 10 ROWS ONLY FOR READ ONLY WITH UR;

  • FETCH FIRST 10 ROWS ONLY -> quer dizer que é pra trazer somente as 10 primeiras linhas encontradas
  • FOR READ -> fala pro banco que esta trazendo dados somente para LEITURA, de forma superficial, quando você não usa isso, o banco deixa CURSORES posicionados na posição dos registros que você trouxe, ja preparando pra um update/delete – isso, consome recursos.
  • WITH UR -> quer dizer “with uncommited records”, ou seja, já traz os dados mais atualizados do banco, que sofreram um update, mesmo não tendo sofrido commit ainda.

Enjoy!

Criando um Event Monitor no DB2

Muitas vezes precisamos logar os eventos que acontecem em nosso banco de dados DB2, normalmente, para monitorar desempenho, queries mais utilizadas, etc.

Criar um Event Monitor é uma das soluções mais simples e rapidas para monitoração. O procedimento abaixo mostra como criar um simples, que vai logar os eventos de seu banco:

— conecte no seu banco: db2 connect to banco user fulano using senha

— Criar o monitor de eventos
db2 “CREATE EVENT MONITOR monjmm FOR STATEMENTS WRITE TO FILE ‘c:\tmp'” — verificar se o destino c:\tmp existe e é possivel escrever no mesmo
 
— liga o monitor de eventos
db2 SET EVENT MONITOR monjmm STATE = 1
 
— Use o banco!
 
— Desligue o monitor de eventos
db2 SET EVENT MONITOR monjmm STATE = 0
 
— torne o output legivel
db2evmon -path c:\tmp > c:\tmp\filtered.out — Tem que dar permissao de leitura para os arquivos criados
 
— veja os eventos abrindo o arquivo com o bloco de notas
notepad c:\tmp\filtered.out
 
— deletar o monitor
db2 DROP EVENT MONITOR monjmm

Enjoy!