Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7058717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:08:45+00:00 2026-05-28T04:08:45+00:00

I was reading the erlang documentation about file io and saw this: On operating

  • 0

I was reading the erlang documentation about file io and saw this:

On operating systems with thread support, it is possible to let file
operations be performed in threads of their own, allowing other Erlang
processes to continue executing in parallel with the file operations.
See the command line flag +A in erl(1).

so what I expected was that the time required for an IO operation would be reduced if I added asynchronous threads.
instead, when I tried running erl +A1,erl +A6 or erl +A12 (on a 6-core machine) the time required to write in a file increased 5-10 times.

I used timer:tc/3 to measure time and I used io:write/2, file:write/2 (converted the term to binary) and file:write/2 while opening the file with the raw flag. the term was ~170kb in size and was written 1000 times. Used R14B04 (but I got similar results with R15A too).

Am I doing something wrong, either in utilizing the asynchronous IO or in measuring its efficiency?

Could it be that the overhead introduced by passing the term (perhaps because its size is small) out-weights the speedup gained?

the (not so elegant :$) code:

-module(test).
-compile(export_all).

test()->
    {ok,F}=file:open(foo,[raw,write]),          % or just [write]
    {T,ok}=timer:tc(test,t,[F,1000]),
    file:close(F),
    T.

t(_,0)->ok;
t(F,A)->
    B=dsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdfdsafasfagafssadagfsdsaasdf,

    file:write(F,
term_to_binary([B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B,B])),
%or io:write(F,[B,..])
    t(F,A-1).

I am interested in minimizing IO overhead (basically just output) because I want to write some data to disk during profiling; that’s why sending the data to some other process that will do the writing is not helpful (unless I could somehow devote a core to a process). So far, the best method seems to be opening a raw file, accumulating data and then writing them; any tips would be appreciated 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:08:46+00:00Added an answer on May 28, 2026 at 4:08 am

    When I run the test I get about the same performance with +A1 and without. This is on OS X Snow Leopard with a dual core processor. This is also what I would expect using async threads.

    Adding async threads only adds additional threads to do IO with and thus increase performance of parallel IO jobs and it also allows normal erlang processes to be run at a faster rate as the process threads are not busy doing IO jobs.

    If you run a test with many parallel jobs you should see a performance gain from using async threads.

    Why you are seeing a performance decrease in your sequential tests is a mystery though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been reading about Erlang lately and how tail-recursion is so heavily used, due
I've been reading a lot about how Scala and Erlang does lightweight threads and
I'm reading about threads and in many books is said that Java support threads
After reading about Erlang's lighweight processes I was pretty much sure that they were
The book I'm reading about Erlang has exercises in the back of it and
I was reading this informative page on Green Thread (Wikipedia) and I wonder: what
It's possible to run the erlang VM inside a process? I'm asking this because
After reading this question Is Erlang the C of the clustered computing world? ,
Not sure if this is advisible but i am reading up on erlang and
I'm reading 512^2 whitespace delimited doubles written in a text file to my Erlang

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.