List all cells' name from input database

edited May 18 in Layout

Hi Matthias,

I tried to write a simple code to list all cells' name from input database,
the following partial code works however the performance is not good enough
when processing database with many cells(more than 10,000~100,000),
is there any way to dump whole database cells' name directly and faster
then the code ? Thanks~

layout.each_cell do |cell|
  puts "#{cell.name}"
end

or

i = 0
while i < layout.cells
  puts "#{layout.cell(i).name}"
  i = i+1
end

Best Regards,

chhung

Comments

  • edited May 18

    Hi chhung,

    The first code is already pretty short. Basically it should not take more than a few seconds even for 100k cells.

    A small optimization is possible by omitting the string interpolation (puts(x) instead of puts("#{x}"))

    I assume the performance is limited by the output method. If you print to the console this will be pretty slow.

    You can try to write the names to a file:

    File.open("cell_names.txt") do |file|
      layout.each_cell do |cell|
        file.puts(cell.name)
      end
    end
    

    Another tip is to disable the debugger or close the macro IDE (you need to bind the script to a menu then). The macro IDE will slow down script execution considerably. For maximum performance you can run the script in batch mode without UI.

    If this still isn't good enough, you have hit the limits of a scripting language, I'm afraid.

    Matthias

  • edited May 19

    Hi Matthias,

    I modified the code and disabled the macros, and tried to write the cell name to file, however the run time is still too long(more than 3 minutes for a 160K cells database)

    layout = RBA::Layout.new
    layout.read("xxx.oas.gz")
    
    File.open("cell_names.txt", "w") do |file|
      layout.each_cell do |cell|
        file.puts(cell.name)
      end
    end
    

    But I noticed that the load time of database is about 17 seconds, the cell name file output completed is about 2 seconds, in theory after all the cell names were generated, the klayout process should close immediately, however it keeps running(CPU load 99~100%) more than 2 minutes then closed.

    The version I am using is 0.24.10, and once I switch the klayout version to 0.25.9 or 0.26.5, the run time decreased to about 19~20 seconds, so maybe it's a bug of old klayout version.

    Thanks for your help~ :smiley:

    Best Regards,

    chhung

Sign In or Register to comment.